#!/usr/bin/env python
# -*- coding: utf-8 -*-

# 源点project_id与game_id 的关系映射

yd_game_projectid = {
    "MuTBYh2Z": {
        "name": "PC市场运营",
        "game_list": ['1511858350596670', '1512700768251970','1513589151254070','1515393944215330','1516780434798580','1516784964701710','1515394027840770','1516784964701710'],
    },
    "MuTBghwZ": {
        "name": "iOS手游运营部",
        "game_list": ['1383532238264530', '1512612253847540'],
    },
    "MuTBkhwZ": {
        "name": "安卓手游市场部",
        "game_list": ['1512714223698730','1516344560612920','1522650166161760','1524188547466470'],
    },
    "MuTBkh0Z":{
        "name":"发行部",
        "game_list": ['1524193853665720'],

    }
}

# 接入源点日志的游戏
yd_game = []
for k, v in yd_game_projectid.items():
    yd_game.extend(v.get("game_list"))

if __name__ == '__main__':
    project_id = "MuTBkhwZ2"
    r_project_id = None
    game_id = "1374740944131310"
    game_flag = None
    msg = ""
    flag = False
    for k, v in yd_game_projectid.items():
        if game_id in v.get("game_list"):
            # game_id 匹配
            r_project_id = k
            r_project_name = v.get("name")
            game_flag = True
            break
    else:
        msg = "该 game_id=%s 在工作台中未配置\n请核实后在工作台中配置" % game_id
    if game_flag:
        if project_id == r_project_id:
            flag = True
            msg = "匹配成功！"
        else:
            msg = "当前project_id=%s \n正确project_id=%s（%s）\n不匹配，请核查。" % (
                project_id, r_project_id, r_project_name)

    ret = {
        "flag": flag,
        "msg": msg,
        "config": yd_game_projectid
    }
    print(ret.get("msg"))
